<link rel="stylesheet" href="__PUBLIC__/css/pintuer.css">
<script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
<script src="__PUBLIC__/js/pintuer.js"></script>
<script src="__PUBLIC__/lib/layer/layer.js"></script>
      <div class="x12 padding-large">
		  <div class="form-group">
			<div class="field">
			 <span class=" padding-right">角色名称 : </span>
			 <input type="text" class="input input-auto box-shadow-none radius-none" value="{$group_info.title}"  name="title" size="20"  />
			</div>
		  </div>
		  <div>角色权限 ：</div>
		<div class="collapse">
		 <volist name="rule_list" id="vo">
		  <div class="panel">
			<div class="panel-head bg-white "><span class="float-right"><label><input type="checkbox" name="rules[]" onclick="checkd(this,1)" <if condition="in_array($vo['id'],$group_info['rules'])">checked</if> value="{$vo.id}" /> 选择</label></span> {$vo.title} </div>
			<div class="panel-body">
				<ul class="list-group">
					<volist name="vo.sub" id="v">
						<li><span class="float-right"><label><input type="checkbox" name="rules[]" value="{$v.id}" onclick="checkd(this,0)"<if condition="in_array($v['id'],$group_info['rules'])">checked</if> /> 选择</label></span>{$v.title}</li>
					</volist>
				</ul>
			</div>
		  </div>
		  </volist>
		 
		</div>
		<div class="text-center clearfiex margin-top">
			<button class="button bg-blue" onclick="rules_save(this)" type="button">保存</button>
		</div>
	  </div>
    </div>
	<script>
		function rules_save(d){
			var title=$("input[name='title']").val();
			var rules=new Array();
			$("input[name='rules[]']:checked").each(function(i,v){
				rules.push($(v).val());
			})
			$.post("__SELF__",{title:title,rules:rules.join(',',rules)},function(ret){
				if(ret.status==1){
					parent.layer.msg(ret.info, {
						offset: 200,
						shift: 2
					});
					parent.window.location.reload()
				}else{
					layer.msg(ret.info, {
						offset: 200,
						shift: 2
					});
				}
			})
		}
		//全选
		function checkd(a,b){
			if(b==1){									
				var c=$(a).parent().parent().parent().parent().find("li input[name='rules[]']");
				$(a).attr('checked',$(a).attr("checked"))
				$(c).attr('checked',!$(c).attr("checked"))
			}
		}
	</script>
